/*    */ package com.zimbra.cs.account.callback;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.AttributeCallback;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DomainStatus
/*    */   extends AttributeCallback
/*    */ {
/*    */   public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 34 */     if (!(value instanceof String)) {
/* 35 */       throw ServiceException.INVALID_REQUEST("zimbraDomainStatus is a single-valued attribute", null);
/*    */     }
/* 37 */     String status = (String)value;
/*    */     
/* 39 */     if (status.equals("shutdown")) {
/* 40 */       throw ServiceException.INVALID_REQUEST("Setting zimbraDomainStatus to shutdown is not allowed.  It is an internal status and can only be set by server", null);
/*    */     }
/* 42 */     if (status.equals("closed")) {
/* 43 */       attrsToModify.put("zimbraMailStatus", "disabled");
/*    */     }
/*    */     else {
/* 46 */       if (entry != null) {
/* 47 */         Domain domain = (Domain)entry;
/* 48 */         if (domain.beingRenamed()) {
/* 49 */           throw ServiceException.INVALID_REQUEST("domain " + domain.getName() + " is being renamed, cannot change " + "zimbraDomainStatus", null);
/*    */         }
/*    */       }
/* 52 */       String alsoModifyingMailStatus = (String)attrsToModify.get("zimbraMailStatus");
/* 53 */       if (alsoModifyingMailStatus == null) {
/* 54 */         if (entry != null) {
/* 55 */           String curMailStatus = entry.getAttr("zimbraMailStatus");
/* 56 */           if ((status.equals("suspended")) && (curMailStatus != null) && (curMailStatus.equals("disabled")))
/*    */           {
/*    */ 
/* 59 */             return;
/*    */           }
/*    */         }
/* 62 */         attrsToModify.put("zimbraMailStatus", "enabled");
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public void postModify(CallbackContext context, String attrName, Entry entry) {}
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/callback/DomainStatus.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */